package org.goldonframework.platform.container;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.goldonframework.platform.util.LoggerFactory;

@SuppressWarnings("static-access")
public class BaseContainerService {
	private static Logger logger = LoggerFactory.getLogger(BaseContainerService.class.getName());
	private static BaseContainer spc;
	static {
		spc = new BaseContainer();
		spc.load("beans.xml");
	}

	public static Object getService(String serviceName) {
		if (StringUtils.isBlank(serviceName)) {
			logger.error("Current Service Name[" + serviceName
					+ "]is Not Exists");
			throw new RuntimeException("Current Service Name is Not Exists");
		}
		Object object = null;
		if (spc.ctx.containsBean(serviceName)) {
			object = spc.ctx.getBean(serviceName);
		}
		if (object == null) {
			logger.error("Current Service Name[" + serviceName
					+ "] which Node Service is Not Exists");
			throw new RuntimeException("Current Service Name[" + serviceName
					+ "] which Node Service is Not Exists");

		}
		return object;
	}

}
